﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Xna.Base;
using RolePlaying;
using Microsoft.Xna.Framework;
using DC2010.Objects;

namespace DC2010
{
    public partial class Hud
    {

        private void DrawSpellSheet()
        {
            SpriteBatch spriteBatch = screenManager.SpriteBatch;
            spriteBatch.Draw(TM.GetTex("Interface/Spellsheet" + Root.I.GameSystem.ActiveCaster.ToString()), RM.Get("SpellSheet").GetVector(), Color.White);

            CreatureData c = Root.I.GameSystem.Party.GetCreatureByIndex(Root.I.GameSystem.ActiveCaster);

            if (c != null)
            {
                int count = 0;

                if (c.SpellSheetSpell == null) count = 0;
                else
                    count = c.SpellSheetSpell.Length;

                if (count == 0)
                {
                    spriteBatch.DrawString(Fonts.DebugFont, "a", RM.Get("SpellSheet_LO").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("a")));
                    spriteBatch.DrawString(Fonts.DebugFont, "b", RM.Get("SpellSheet_UM").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("b")));
                    spriteBatch.DrawString(Fonts.DebugFont, "c", RM.Get("SpellSheet_ON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("c")));
                    spriteBatch.DrawString(Fonts.DebugFont, "d", RM.Get("SpellSheet_EE").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("d")));
                    spriteBatch.DrawString(Fonts.DebugFont, "e", RM.Get("SpellSheet_PAL").GetVector() + new Vector2(6, 4), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("e")));
                    spriteBatch.DrawString(Fonts.DebugFont, "f", RM.Get("SpellSheet_MON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("f")));
                }

                if (count == 1)
                {
                    spriteBatch.DrawString(Fonts.DebugFont, "g", RM.Get("SpellSheet_LO").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("g")));
                    spriteBatch.DrawString(Fonts.DebugFont, "h", RM.Get("SpellSheet_UM").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("h")));
                    spriteBatch.DrawString(Fonts.DebugFont, "i", RM.Get("SpellSheet_ON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("i")));
                    spriteBatch.DrawString(Fonts.DebugFont, "j", RM.Get("SpellSheet_EE").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("j")));
                    spriteBatch.DrawString(Fonts.DebugFont, "k", RM.Get("SpellSheet_PAL").GetVector() + new Vector2(6, 4), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("k")));
                    spriteBatch.DrawString(Fonts.DebugFont, "l", RM.Get("SpellSheet_MON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("l")));
                }

                if (count == 2)
                {
                    spriteBatch.DrawString(Fonts.DebugFont, "m", RM.Get("SpellSheet_LO").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("m")));
                    spriteBatch.DrawString(Fonts.DebugFont, "n", RM.Get("SpellSheet_UM").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("n")));
                    spriteBatch.DrawString(Fonts.DebugFont, "o", RM.Get("SpellSheet_ON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("o")));
                    spriteBatch.DrawString(Fonts.DebugFont, "p", RM.Get("SpellSheet_EE").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("p")));
                    spriteBatch.DrawString(Fonts.DebugFont, "q", RM.Get("SpellSheet_PAL").GetVector() + new Vector2(6, 4), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("q")));
                    spriteBatch.DrawString(Fonts.DebugFont, "r", RM.Get("SpellSheet_MON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("r")));
                }

                if (count == 3)
                {
                    spriteBatch.DrawString(Fonts.DebugFont, "s", RM.Get("SpellSheet_LO").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("s")));
                    spriteBatch.DrawString(Fonts.DebugFont, "t", RM.Get("SpellSheet_UM").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("t")));
                    spriteBatch.DrawString(Fonts.DebugFont, "u", RM.Get("SpellSheet_ON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("u")));
                    spriteBatch.DrawString(Fonts.DebugFont, "v", RM.Get("SpellSheet_EE").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("v")));
                    spriteBatch.DrawString(Fonts.DebugFont, "w", RM.Get("SpellSheet_PAL").GetVector() + new Vector2(6, 4), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("w")));
                    spriteBatch.DrawString(Fonts.DebugFont, "x", RM.Get("SpellSheet_MON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("x")));
                }

                if (count == 4)
                {
                    spriteBatch.DrawString(Fonts.DebugFont, "{", RM.Get("SpellSheet_LO").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("{")));
                    spriteBatch.DrawString(Fonts.DebugFont, "}", RM.Get("SpellSheet_UM").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("}")));
                    spriteBatch.DrawString(Fonts.DebugFont, "[", RM.Get("SpellSheet_ON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("[")));
                    spriteBatch.DrawString(Fonts.DebugFont, "]", RM.Get("SpellSheet_EE").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("]")));
                    spriteBatch.DrawString(Fonts.DebugFont, "#", RM.Get("SpellSheet_PAL").GetVector() + new Vector2(6, 4), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("#")));
                    spriteBatch.DrawString(Fonts.DebugFont, "$", RM.Get("SpellSheet_MON").GetVector() + new Vector2(6, 3), Tools.GetColor(Root.I.RuneSystem.GetRuneColor("$")));
                }

                spriteBatch.DrawString(Fonts.DebugFont, SpaceSpell(c.SpellSheetSpell), RM.Get("SpellSheet_CAST").GetVector() + new Vector2(6, 3), Color.White);
            }

            spriteBatch.DrawString(Fonts.DebugFont, "y", RM.Get("SpellSheet_BACK").GetVector() + new Vector2(6, 3), Color.White);
        }

        public string SpaceSpell(string spell)
        {
            string output = "";
            if (spell != null)
            {
                foreach (char c in spell)
                {
                    output += c + "  ";
                }
            }

            return output;
        }

    }
}
